<?php

namespace app\admin\model;

use think\Model;

class Userlog extends Model
{
    // 设置当前模型对应的完整数据表名称
    protected $table = 'sact_user_log';

    protected $autoWriteTimestamp = true;

    public static function addUserlog($userid,$nickname,$server_ip,$server_hostname) {
        try {
            $now = date("Y-m-d H-i-s",time());
            $data = array(
                'userid'          =>  $userid,
                'nickname'        =>  $nickname,
                'server_ip'       =>  $server_ip,
                'server_hostname' =>  $server_hostname,
                'logintime'       =>  $now,
                'create_time'     =>  time(),
            );
            $log = db('sact_user_log')->insert($data);
            if($log){
                return 0;
            }
        } catch ( Exception $e ) {
            return -1;
        }
    }

}